package org.admanager.soageneralpattern.plugin.soageneralpattern.diagram.part;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.admanager.soageneralpattern.plugin.soageneralpattern.diagram.providers.GeneralSOAPatternECOREMetamodelElementTypes;
import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

/**
 * @generated
 */
public class GeneralSOAPatternECOREMetamodelPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createPatternElement1Group());
		paletteRoot.add(createPatternConnector2Group());
		paletteRoot.add(createSOAElement3Group());
		paletteRoot.add(createSOAConnector4Group());
	}

	/**
	 * Creates "Pattern Element" palette tool group
	 * @generated
	 */
	private PaletteContainer createPatternElement1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.PatternElement1Group_title);
		paletteContainer.setId("createPatternElement1Group"); //$NON-NLS-1$
		paletteContainer.add(createRole1CreationTool());
		paletteContainer.add(createConstraint2CreationTool());
		paletteContainer.add(createMultiplicity3CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Pattern Connector" palette tool group
	 * @generated
	 */
	private PaletteContainer createPatternConnector2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.PatternConnector2Group_title);
		paletteContainer.setId("createPatternConnector2Group"); //$NON-NLS-1$
		paletteContainer.add(createElementtoRole1CreationTool());
		paletteContainer.add(createElementtoMultiplicity2CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "SOA Element" palette tool group
	 * @generated
	 */
	private PaletteContainer createSOAElement3Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.SOAElement3Group_title);
		paletteContainer.setId("createSOAElement3Group"); //$NON-NLS-1$
		paletteContainer.add(createComponent1CreationTool());
		paletteContainer.add(createComponentReference2CreationTool());
		paletteContainer.add(createComponentService3CreationTool());
		paletteContainer.add(createComposite4CreationTool());
		paletteContainer.add(createReference5CreationTool());
		paletteContainer.add(createService6CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "SOA Connector" palette tool group
	 * @generated
	 */
	private PaletteContainer createSOAConnector4Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.SOAConnector4Group_title);
		paletteContainer.setId("createSOAConnector4Group"); //$NON-NLS-1$
		paletteContainer
				.add(createReferencetoComponentReference1CreationTool());
		paletteContainer.add(createServicetoComponentService2CreationTool());
		paletteContainer
				.add(createComponentReferencetoComponentService3CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRole1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Role1CreationTool_title,
				Messages.Role1CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.Role_2004));
		entry.setId("createRole1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.Role_2004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConstraint2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Constraint2CreationTool_title,
				Messages.Constraint2CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.Constraint_3006));
		entry.setId("createConstraint2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.Constraint_3006));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createMultiplicity3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Multiplicity3CreationTool_title,
				Messages.Multiplicity3CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.Multiplicity_2003));
		entry.setId("createMultiplicity3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.Multiplicity_2003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createElementtoRole1CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ElementtoRole1CreationTool_title,
				Messages.ElementtoRole1CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.ElementRoles_4001));
		entry.setId("createElementtoRole1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createElementtoMultiplicity2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ElementtoMultiplicity2CreationTool_title,
				Messages.ElementtoMultiplicity2CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.ElementMultiplicity_4002));
		entry.setId("createElementtoMultiplicity2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponent1CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(GeneralSOAPatternECOREMetamodelElementTypes.Component_2001);
		types.add(GeneralSOAPatternECOREMetamodelElementTypes.Component_3005);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Component1CreationTool_title,
				Messages.Component1CreationTool_desc, types);
		entry.setId("createComponent1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.Component_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentReference2CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(GeneralSOAPatternECOREMetamodelElementTypes.ComponentReference_3002);
		types.add(GeneralSOAPatternECOREMetamodelElementTypes.ComponentReference_3008);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ComponentReference2CreationTool_title,
				Messages.ComponentReference2CreationTool_desc, types);
		entry.setId("createComponentReference2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.ComponentReference_3002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentService3CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(GeneralSOAPatternECOREMetamodelElementTypes.ComponentService_3001);
		types.add(GeneralSOAPatternECOREMetamodelElementTypes.ComponentService_3007);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ComponentService3CreationTool_title,
				Messages.ComponentService3CreationTool_desc, types);
		entry.setId("createComponentService3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.ComponentService_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComposite4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Composite4CreationTool_title,
				Messages.Composite4CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.Composite_2002));
		entry.setId("createComposite4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.Composite_2002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createReference5CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Reference5CreationTool_title,
				Messages.Reference5CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.Reference_3003));
		entry.setId("createReference5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.Reference_3003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createService6CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Service6CreationTool_title,
				Messages.Service6CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.Service_3004));
		entry.setId("createService6CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelElementTypes
				.getImageDescriptor(GeneralSOAPatternECOREMetamodelElementTypes.Service_3004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createReferencetoComponentReference1CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ReferencetoComponentReference1CreationTool_title,
				Messages.ReferencetoComponentReference1CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.ReferencePromote_4003));
		entry.setId("createReferencetoComponentReference1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createServicetoComponentService2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ServicetoComponentService2CreationTool_title,
				Messages.ServicetoComponentService2CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.ServicePromote_4004));
		entry.setId("createServicetoComponentService2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentReferencetoComponentService3CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ComponentReferencetoComponentService3CreationTool_title,
				Messages.ComponentReferencetoComponentService3CreationTool_desc,
				Collections
						.singletonList(GeneralSOAPatternECOREMetamodelElementTypes.ComponentReferenceTarget_4005));
		entry.setId("createComponentReferencetoComponentService3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralSOAPatternECOREMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
